package com.sunda.spmsoversea.mapper;

import com.sunda.spmsoversea.entity.OverseaOtherDtl;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;

/**
 * <p>
 * 海外仓其他出入库明细 Mapper 接口
 * </p>
 *
 * @author Wayne
 * @since 2021-12-27
 */
@Mapper
public interface OverseaOtherDtlMapper extends BaseMapper<OverseaOtherDtl> {

    @Select("SELECT OOD.AUTO_ID_OTHER AS \"autoIdOther\",\n" +
            "       OOD.UUID AS \"uuid\",\n" +
            "       OOD.ITEM AS \"item\",\n" +
            "       OOD.WERKS AS \"werks\",\n" +
            "       OOD.WORKSHOP_CODE AS \"workshopCode\",\n" +
            "       OOD.WHS_LOCATION_CODE AS \"whsLocationCode\",\n" +
            "       OOD.MATERIAL_NO AS \"materialNo\",\n" +
            "       SAP.MATERIAL_ZH_DESC AS \"materialZhDesc\",\n" +
            "       SAP.MATERIAL_EN_DESC AS \"materialEnDesc\",\n" +
            "       OOD.ACTUAL_QTY_BASIC_UNIT AS \"actualQtyBasicUnit\",\n" +
            "       OOD.STORAGE_INFO AS \"storageInfo\",\n" +
            "       OOD.BASIC_UNIT AS \"basicUnit\",\n" +
            "       OOD.COST_CENTER AS \"costCenter\",\n" +
            "       OOD.MATERIAL_NO_ADJUSTED AS \"materialNoAdjusted\",\n" +
            "       MS.MATERIAL_ZH_DESC AS \"materialZhDescAdjusted\",\n" +
            "       MS.MATERIAL_EN_DESC AS \"materialEnDescAdjusted\",\n" +
            "       OOD.ACTUAL_QTY_BASIC_UNIT_ADJUSTED AS \"actualQtyBasicUnitAdjusted\",\n" +
            "       OOD.STORAGE_INFO_ADJUSTED AS \"storageInfoAdjusted\",\n" +
            "       OOD.SUPPLIER_NO AS \"supplierNo\",\n" +
            "       OOD.SAP_DELIVERY_NOTE AS \"sapDeliveryNote\",\n" +
            "       OOD.SAP_DELIVERY_NOTE_ITEM AS \"sapDeliveryNoteItem\",\n" +
            "       OOD.REMARKS AS \"remarks\",\n" +
            "       OOD.COMMENTS AS \"comments\",\n" +
            "       OOD.INTERNAL_ORDER_NUMBER AS \"internalOrderNumber\",\n" +
            "       OOD.LOCAL_CURRENCY AS \"localCurrency\"\n" +
            "FROM OVERSEA_OTHER_DTL OOD\n" +
            "    LEFT JOIN MATERIAL_SAP SAP ON OOD.MATERIAL_NO = SAP.MATERIAL_NO\n" +
            "    LEFT JOIN MATERIAL_SAP MS ON OOD.MATERIAL_NO_ADJUSTED = MS.MATERIAL_NO \n" +
            "WHERE OOD.UUID = #{uuid}\n" +
            "ORDER BY TO_NUMBER(OOD.ITEM) ASC ")
    List<Map<String, Object>> getOtherDtlList(@Param("uuid") String uuid);
}
